<template>
  <div>
    <el-form ref="ruleForm" :inline="false" class="elForm" :class="isEdit?'':'formItem'">
      <el-card class="box-card" shadow="never">

        <div slot="header" class="header-card" style="display: flex;justify-content: space-between">
          <span class="header-card-title">申请信息</span>
          <div v-if="buttonBoolean">
            <!--常规出自预警-->
            <template v-if="boole === 'RoutineApplyForList'">
              <el-button size="mini" type="primary" @click="handleCancel"
                         v-if="[2].includes(Number(ruleForm.disposalStatus))">
                撤销处置
              </el-button>

              <el-button size="mini" type="primary" @click="handleTransferOwnership"
                         v-if="[9].includes(Number(ruleForm.disposalStatus))">
                车辆过户
              </el-button>
            </template>

            <!--常规处置处理-->
            <template v-if="boole === 'RoutineHandleList'">
              <el-button size="mini" type="primary" @click="handleSubmitResult(ruleForm)"
                         v-if="[2,5].includes(Number(ruleForm.disposalStatus))">
                提交处置结果
              </el-button>

              <el-button size="mini" type="primary" @click="handleSalvageValue(ruleForm)"
                         v-if="[2].includes(Number(ruleForm.disposalStatus))">
                修改残值
              </el-button>

              <el-button size="mini" type="primary" @click="handleUploadContract(ruleForm)"
                         v-if="[6].includes(Number(ruleForm.disposalStatus))">
                上传合同
              </el-button>

              <el-button size="mini" type="primary" @click="handleUnderwriterDefault(ruleForm)"
                         v-if="[6,7,8,9].includes(Number(ruleForm.disposalStatus))">
                承销商违约
              </el-button>

              <el-button size="mini" type="primary" @click="handleSubmitPaymentProof(ruleForm)"
                         v-if="[7].includes(Number(ruleForm.disposalStatus))">
                提交付款凭证
              </el-button>

              <el-button size="mini" type="primary" @click="handleSubmitProcedure(ruleForm)"
                         v-if="[10].includes(Number(ruleForm.disposalStatus))">
                提交手续
              </el-button>
            </template>

          </div>

        </div>
        <el-row :gutter="10">
          <el-col :span="status">
            <el-row :gutter="20">
              <el-col :span="8">
                <el-form-item label="车牌号:">
                  <span>{{ ruleForm.carNo }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="车架号:">
                  <span>{{ ruleForm.vinNo }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="品牌/车系/车型:">
                  <span>{{ ruleForm.brandName }}/{{ ruleForm.seriesName }}/{{ ruleForm.modelName }}</span>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item label="车辆产权:">
                  <span>{{ ruleForm.propertyRightName }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="登记日期:">
                  <span>{{ ruleForm.registerTime }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="车龄:">
                  <span>{{ ruleForm.carAge }}</span>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item label="排放标准:">
                  <span>{{ ruleForm.environmentalStandards }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="燃油类型:">
                  <span>  {{ selectDictLabel(dict.type.fuel_type, ruleForm.fuelType) }}</span>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item label="排量:">
                  <span>{{ ruleForm.liter }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="座位数:">
                  <span>{{ ruleForm.seatNum }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="档位:">
                  <span>{{ ruleForm.gearPosition }}</span>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item label="颜色:">
                  <span>{{ ruleForm.exteriorColor }}</span>
                </el-form-item>
              </el-col>
<!--              <el-col :span="8">-->
<!--                <el-form-item label="登记类型:">-->
<!--                  <span>  {{ selectDictLabel(dict.type.car_nature, ruleForm.carNature) }}</span>-->
<!--                </el-form-item>-->
<!--              </el-col>-->
              <el-col :span="8">
                <el-form-item label="上三年出险金额(元):">
                  <span>{{ format_thousand(ruleForm.accidentAmountThreeYears) }}</span>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item label="指导价(元):">
                  <span>{{ format_thousand(ruleForm.guidancePrice) }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="采购价(元):">
                  <span>{{ format_thousand(ruleForm.purchasePrice) }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="初期残值(元):">
                  <span>{{ format_thousand(ruleForm.initialResidualValue) }}</span>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item label="公里数:">
                  <span>{{ ruleForm.mileage }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="过户次数:">
                  <span>{{ ruleForm.transferCount }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="车况等级:">
                <span> {{ selectDictLabel(dict.type.vehicle_condition_level_type, ruleForm.vehicleConditionLevel) }}
                </span>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item label="车辆停放城市:">
                  <span>{{ ruleForm.cityName }}</span>
                </el-form-item>
              </el-col>

            </el-row>
            <el-row :gutter="20">
              <el-col :span="24" style="padding-top: 10px">
                <el-form-item label="处置原因:">
                  <span>{{ ruleForm.disposalReason }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="24" style="padding-top: 10px">
                <el-form-item label="车辆异常:">
                  <span>{{ ruleForm.vehicleStatus }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="24" style="padding-top: 10px">
                <el-form-item label="附件:">
                  <image-common v-model="ruleForm.attachment" :limit="20" :disabled="true" :upType="2"/>
                </el-form-item>
              </el-col>
            </el-row>
          </el-col>

          <el-col :span="24 - status" v-if="status < 24">
            <div class="div-status">
              {{ selectDictLabel(dict.type.disposal_status_type, ruleForm.disposalStatus) }}
            </div>
          </el-col>
        </el-row>

      </el-card>
    </el-form>
    <transfer-ownership ref="refTransferOwnership"/>

    <!--上传合同-->
    <uploadContractDialog ref="refUploadContractDialog" @successUploadContract="successList"/>
    <!--承销商违约-->
    <underwriterDefault ref="refUnderwriterDefault" @refresh="successList"/>
    <!--提交付款凭证-->
    <paymentDocument ref="refPaymentDocument" @refresh="successList"/>
    <!-- 提交手续-->
    <submitProcedure ref="refSubmitProcedure" @refresh="successList"/>
  </div>
</template>

<script>
export default {
  name: 'newApplicationInfo',//申请信息 不带输入框
  dicts: [
    'fuel_type',
    'vehicle_condition_level_type',
    'car_nature',
    'disposal_status_type'
  ],
  props: {
    value: {
      type: Object,
      default: () => {
        return {};
      },
    },
    state: {
      type: String,
      default: "",
    },
    status: {
      type: Number,
      default: 24
    },
    buttonBoolean: {
      type: Boolean,
      default: false
    }
  },
  components: {
    transferOwnership: () => import('./transferOwnership.vue'),
    uploadContractDialog: () => import('../routineHandle/uploadContractDialog.vue'),
    underwriterDefault: () => import('../routineHandle/underwriterDefault.vue'),
    paymentDocument: () => import('../routineHandle/paymentDocument.vue'),
    submitProcedure: () => import('../routineHandle/submitProcedure.vue'),
  },
  computed: {
    ruleForm: {
      get() {
        let that = this
        const proxy = new Proxy(that.value, {
          get(target, key, value) {
            return Reflect.get(target, key)
          }
        })
        return proxy
      }
    },
    isEdit() {
      let bool;
      switch (this.state) {
        case "write":
          bool = true;
          break;
        case "disabled":
          bool = false;
          break;
        case "readonly":
          bool = false;
          break;
      }
      return bool
    },
    boole() {
      let a = ''
      if (this.$route.query.path === 'RoutineApplyForList') {
        return a = 'RoutineApplyForList'
      }
      if (this.$route.query.path === 'RoutineHandleList') {
        return a = 'RoutineHandleList'
      }
      return a
    }
  },
  watch: {},
  data() {
    return {};
  },
  created() {
  },
  mounted() {
  },
  methods: {
    //撤销
    handleCancel() {
      this._toPage({
        path: "/VehicleDisposal/RoutineDisposal/RoutineApplyForCancel",
        name: 'RoutineApplyForCancel',
        query: {
          type: "view",
          id: this.$route.query.id,
          path: this.$route.query.path,
        }
      })
    },

    //车辆过户
    handleTransferOwnership() {
      this.$refs.refTransferOwnership.handleOpen()
    },

    //提交处置结果
    handleSubmitResult(row) {
      this._toPage({
        path: "/VehicleDisposal/RoutineDisposal/SubmitResult",
        name: "SubmitResult",
        query: {
          type: "view",
          id: row.vehicleDisposalId
        },
      });
    },

    //修改残值
    handleSalvageValue(row) {
      this._toPage({
        path: "/VehicleDisposal/RoutineDisposal/EditSalvage",
        name: "EditSalvage",
        query: {
          type: "view",
          id: row.vehicleDisposalId
        },
      });
    },

    //上传合同
    handleUploadContract(row) {
      this.$refs.refUploadContractDialog.handleOpen(row.vehicleDisposalId)
    },

    //承销商违约
    handleUnderwriterDefault(row) {
      this.$refs.refUnderwriterDefault.handleOpen(row)
    },

    //提交付款凭证
    handleSubmitPaymentProof(row) {
      this.$refs.refPaymentDocument.handleOpen(row)
    },

    //提交手续
    handleSubmitProcedure(row) {
      this.$refs.refSubmitProcedure.handleOpen(row)
    },

    //上传合同成功  承销商违约
    successList() {
      this.$emit('successList')
    },
  },
};
</script>

<style lang="scss" scoped>
@import "@/styles/cwgd/formScss.scss";

.elForm {
  .el-form-item {
    width: 100%;
  }
}

.div-status {
  width: 100px;
  height: 100px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  border: 1px solid rgb(64, 158, 255);;
}
::v-deep span:empty::before {
  content: '-';
}
el-row {
  display: flex;
  flex-wrap: wrap;
}
</style>


